#include <iostream>
#include<cmath> 
using namespace std;
int main ()
{char c[1000] ;
 while(gets(c)&&c[0]!='#')
 {int sum=0;
  int a=strlen(c);
    for(int i=0;i<a;i++)
    {if(c[i]>='A'&&c[i]<='Z')  sum +=(i+1)*(c[i]-64);
    }
  cout<<sum<<endl;
  }
system("pause");
return 0;
}
  
 
